<?php

class LShortURL {

    static public function getShortURL($long_url){
		require_once("/lib/snoopy.class.php");
		$snoopy = new Snoopy();
//		LSnoopyMask::mask(&$snoopy);
		if($snoopy->fetch("http://is.gd/create.php?format=simple&url=" . $long_url)){
			return $snoopy->results;
		}
		return null;
	}
	
//	static public function shortenGoogleUrl($long_url){
//		$apiKey = 'AIzaSyDLRV7YwP6-kwH8c5YUq5bnq2XdeH0WbnQ'; //Get API key from : http://code.google.com/apis/console/
//		$postData = array('longUrl' => $long_url, 'key' => $apiKey);
//		$jsonData = json_encode($postData);
//		$curlObj = curl_init();
//		curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url');
//		curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
//		curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
//		curl_setopt($curlObj, CURLOPT_HEADER, 0);
//		curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
//		curl_setopt($curlObj, CURLOPT_POST, 1);
//		curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);
//		$response = curl_exec($curlObj);
//		curl_close($curlObj);
//		$json = json_decode($response);
//		return $json->id;
//	}
//	
//	function expandGoogleUrl($short_url){
//		$curlObj = curl_init();
//		curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url?shortUrl='.$short_url);
//		curl_setopt($curlObj, CURLOPT_HEADER, 0);
//		curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
//		curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
//		$response = curl_exec($curlObj);
//		curl_close($curlObj);
//		$json = json_decode($response);
//		return $json->longUrl;
//	}
}
?>